﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>活动报名</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" />
    <link href="../Frozenui1.3/css/frozen.css" rel="stylesheet" />
    <link href="../CSS/fs_gallery.css" rel="stylesheet" />
    <script src="../JS/layer/layer.m.js"></script>
    <script src="../JS/zepto.min.js"></script>
    <script src="../Frozenui1.3/js/frozen.js"></script>
    <script src="../JS/avalon.mobile.min.js"></script>
    <script src="../JS/MobileCom.js?v=1.1"></script>
    <script src="../JS/fs_gallery.js"></script>
    <script>
        document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
            //隐藏右上角按钮
            WeixinJSBridge.call('hideOptionMenu');
        });
        var strId = MobileCom.getQueryString("ID");
        var hdinfo = avalon.define({
            $id: "hdinfo",
            modelData: {},
            num: 0,
            status: "未报名",
            plData: {},
            plcount: 0,
            nowuser: "",
            imgurl: "",
            isbj: "",
            tpData: [],
            bmData: { "HDID": strId, "BMLxr": "", "BMLxDH": "", "BMCount": "" },
            ckbm: function () {
                window.location = "UI_HDBM_ITEM.html?id=" + strId + "&r=" + Math.random();
            },
            fdtp: function (obj) {
                if (!$(".fs_gallery").html()) {
                    $('.mall_pcp').fsgallery();
                    $(obj).trigger("click");
                }
            },
            bmcj: function () {

                var tc = layer.open({
                    type: 1,
                    //content:$("#bmxx").html(),
                    title: "报名信息",
                    content: '<div class="ui-form ui-border-t" ><div class="ui-form-item ui-border-b"><label>联系人姓名</label><input type="text" placeholder="请输入联系人姓名" id="lxr" value="' + hdinfo.bmData.BMLxr + '" /></div><div class="ui-form-item ui-border-b"><label>联系人手机</label><input type="tel" placeholder="请输入联系人手机" id="lxrsj" value="' + hdinfo.bmData.BMLxDH + '" /></div><div class="ui-form-item ui-border-b"><label>报名人数</label><input type="tel" placeholder="请输入报名人数" id="bmrs" value="' + hdinfo.bmData.BMCount + '" /></div></div>',
                    btn: ['确认', '取消'],
                    shadeClose: false,
                    yes: function () {

                        if ($("#lxr").val() == "") {
                            //$.tips({
                            //    content: "请输入联系人姓名",
                            //    stayTime: 2000,
                            //    type: "warn"
                            //})
                            alert("请输入联系人姓名");
                            return;
                        }
                        if ($("#lxrsj").val() == "") {
                            //$.tips({
                            //    content: "请输入联系人手机",
                            //    stayTime: 2000,
                            //    type: "warn"
                            //})
                            alert("请输入联系人手机");
                            return;
                        }
                        else {
                            var reg = /^(?:13\d|14\d|15\d|17\d|18\d)-?\d{5}(\d{3}|\*{3})$/;
                            if (!reg.test($("#lxrsj").val())) {
                                //$.tips({
                                //    content: "联系人手机格式错误",
                                //    stayTime: 2000,
                                //    type: "warn"
                                //})
                                alert("联系人手机格式错误");
                                return;
                            }
                        }
                        if ($("#bmrs").val() == "") {
                            //$.tips({
                            //    content: "请输入报名人数",
                            //    stayTime: 2000,
                            //    type: "warn"
                            //})
                            alert("请输入报名人数");
                            return;
                        }
                        else {
                            var reg = /^\+?[1-9][0-9]*$/;
                            if (!reg.test($("#bmrs").val())) {
                                //$.tips({
                                //    content: "报名人数输入错误",
                                //    stayTime: 2000,
                                //    type: "warn"
                                //})
                                alert("报名人数输入错误");
                                return;
                            }
                            else {
                                if (parseInt($("#bmrs").val()) > 100) {
                                    //$.tips({
                                    //    content: "报名人数必须小于100",
                                    //    stayTime: 2000,
                                    //    type: "warn"
                                    //})
                                    alert("报名人数必须小于100");
                                    return;
                                }
                            }
                        }

                        hdinfo.bmData.BMCount = $("#bmrs").val();
                        hdinfo.bmData.BMLxDH = $("#lxrsj").val();
                        hdinfo.bmData.BMLxr = $("#lxr").val();

                        var lg = $.loading({
                            content: '保存中...',
                        })

                        $.getJSON('/API/WXAPI.ashx?Action=ADDHDBMITEM&r=' + Math.random(), { P1: JSON.stringify(hdinfo.bmData.$model) }, function (resultData) {
                            lg.hide();
                            if (resultData.ErrorMsg == "") {
                                layer.close(tc);
                                $("#bmcj").hide();
                                var el = $.tips({
                                    content: "保存成功",
                                    stayTime: 2000,
                                    type: "success"
                                })
                                el.on("tips:hide", function () {
                                    window.location.reload();
                                })
                            }
                            else {
                                //$.tips({
                                //    content: "保存失败，原因：" + resultData.ErrorMsg,
                                //    stayTime: 2000,
                                //    type: "warn"
                                //})
                                alert("保存失败，原因：" + resultData.ErrorMsg);
                            }

                        })
                    }, no: function () {
                    }
                })
            },
            scpl: function (plel) {
                var tc = layer.open({
                    content: '确定要删除此评论吗？',
                    btn: ['确定', '取消'],
                    shadeClose: false,
                    yes: function () {
                        layer.close(tc);
                        var lg = $.loading({
                            content: '删除中...',
                        })
                        $.getJSON('/API/WXAPI.ashx?Action=DELTL&r=' + Math.random(), { P1: plel.ID }, function (resultData) {
                            lg.hide();
                            if (resultData.ErrorMsg == "") {
                                hdinfo.plData.remove(plel);
                                hdinfo.plcount = hdinfo.plcount - 1;
                                var el = $.tips({
                                    content: "删除成功",
                                    stayTime: 2000,
                                    type: "success"
                                })
                                el.on("tips:hide", function () {
                                    //window.location.reload();
                                })
                            }
                            else {
                                $.tips({
                                    content: "删除失败，原因：" + resultData.ErrorMsg,
                                    stayTime: 2000,
                                    type: "warn"
                                })
                            }
                        })
                    }, no: function () {
                    }
                })
            }
        });
        avalon.ready(function () {
            if (strId != null) {
                var lg = $.loading({
                    content: '加载中...',
                })
                $.getJSON('/API/WXAPI.ashx?Action=GETUSERHDBMLIST&Id=' + strId + '&r=' + Math.random(), {}, function (resultData) {
                    lg.hide();
                    if (resultData.ErrorMsg == "") {
                        hdinfo.modelData = resultData.Result[0];
                        hdinfo.plData = resultData.Result[0].PLList;
                        hdinfo.plcount = resultData.Result[0].PLList.length;
                        hdinfo.tpData = resultData.Result[0].FileList;
                        if (!MobileCom.compareTime(resultData.Result[0].HDBMEndTime, "")) {
                            $("#bmcj").show();
                        }
                        var str = resultData.Result[0].itemUser;
                        if (!(str == "" || str == null || str == "null")) {
                            hdinfo.status = "已报名";
                            $("#bmcj").text("已报名");
                            $.getJSON('/API/WXAPI.ashx?Action=GETHDBMITEMBYUSER&r=' + Math.random(), { P1: strId }, function (resultData) {
                                if (resultData.ErrorMsg == "") {
                                    var data = resultData.Result;
                                    hdinfo.bmData = data;
                                }
                            })
                        }

                        $.post("/API/SZHLAPI.ashx?Action=GetUserInfo&r=" + Math.random(), {}, function (data) {

                            var data = $.parseJSON(data);
                            if (data.ErrorMsg == "") {
                                hdinfo.nowuser = data.Result.User.UserName;
                                if (data.Result.User.UserName == resultData.Result[0].CRUser) {
                                    hdinfo.isbj = "Y";
                                }
                            }
                        });
                    }
                })

                $.getJSON('/API/WXAPI.ashx?Action=GETHDBMITEM&r=' + Math.random(), { P1: strId }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        var data = resultData.Result;
                        for (var i = 0; i < data.length; i++) {
                            hdinfo.num = hdinfo.num + data[i].BMCount;
                        }
                    }
                    if (hdinfo.num > 0) {
                        $("#ckbm").show();
                    }
                })
                $("button.ui-btn").click(function () {
                    if ($("#content").val() == null || $("#content").val() == "") {
                        $.tips({
                            content: "请输入评论内容",
                            stayTime: 2000,
                            type: "warn"
                        })
                        return;
                    }
                    var lg = $.loading({
                        content: '加载中...',
                    })
                    $.getJSON('/API/WXAPI.ashx?Action=ADDCOMENT&r=' + Math.random(), { "P1": $("#content").val(), "MsgType": "HDBM", "MsgLYID": strId }, function (resultData) {
                        lg.hide();
                        if (resultData.ErrorMsg == "") {
                            hdinfo.plData.push(resultData.Result);
                            hdinfo.plcount = hdinfo.plcount + 1;
                            var el = $.tips({
                                content: "评论成功！！",
                                stayTime: 2000,
                                type: "success"
                            })
                            $("#content").val("");
                        }
                        else {
                            var el = $.tips({
                                content: "评论失败！！",
                                stayTime: 2000,
                                type: "warn"
                            })
                        }
                    })
                });
                $.post("/API/SZHLAPI.ashx?Action=GetUserInfo&r=" + Math.random(), {}, function (data) {

                    var data = $.parseJSON(data);
                    if (data.ErrorMsg == "") {
                        if (data.Result.QYinfo.FileServerUrl) {
                            var str = data.Result.QYinfo.FileServerUrl;
                            if (str.substr(str.length - 1, 1) != "/") {
                                str = str + "/";
                            }
                            hdinfo.imgurl = str;
                        }
                    }
                })
            }

        })
        function issc(str) {
            if (str == hdinfo.nowuser) {
                return '<div class="ui-badge-corner" style=" position: relative; " ms-click="scpl(el)">删除</div>';
            }
            else {
                return '';
            }
        }
        function back() {
            window.location.replace("UI_HDBM_LIST.html?r=" + Math.random());
        }
    </script>
    <style>
        .ui-list > li {
            margin: 3px;
            padding-left: 15px;
        }

        .ui-form-item .wspan {
            width: 100%;
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
            -webkit-appearance: none;
            border: 0;
            background: 0 0;
            padding-left: 95px;
        }

        .ms-controller, [ms-controller] {
            display: none;
        }

        .ui-form-item .span img {
            height: auto !important;
            width: auto\9 !important;
            width: 100% !important;
        }

        .ui-form-item .span {
            line-height: 1.5 !important;
            padding-bottom: 10px;
            overflow: hidden;
            word-wrap: break-word;
        }
    </style>

</head>
<body ms-controller="hdinfo">
    <header class="ui-header ui-header-stable ui-border-b">
        <i class="ui-icon-return" onclick="back()"></i>
        <h1>活动信息查看</h1>
        <!--<a class="ui-btn ui-btn-primary" ms-if="isbj" ms-href="UI_HDBM_INPUT.html?ID={{modelData.ID}}" style="color:white">修改</a>-->
    </header>
    <div class="ui-footer ui-footer-stable ui-btn-group ui-border-t">
        <section class="ui-input-wrap ui-border-t" style="width:100%">
            <div class="ui-input ui-border-radius">
                <input id="content" type="text" name="" value="" placeholder="我也说一句...">
            </div>
            <button class="ui-btn">评论</button>
        </section>
    </div>
    <section class="ui-container">
        <div class="ui-form ui-border-t">
            <div class="ui-form-item ui-border-b" style="height:auto">
                <label>
                    发起方
                </label>
                <span class="wspan" style="overflow: hidden; word-wrap: break-word;">{{modelData.HDFQF}}</span>
            </div>
            <div class="ui-form-item ui-border-b">
                <label>
                    活动时间
                </label>
                <span class="wspan">{{modelData.HDTime|date("yyyy-MM-dd")}}</span>
            </div>
            <div class="ui-form-item ui-border-b">
                <label>
                    报名截止
                </label>
                <span class="wspan">{{modelData.HDBMEndTime|date("yyyy-MM-dd HH:mm")}}</span>
            </div>
            <div class="ui-form-item ui-border-b" style="height:auto">
                <label>
                    活动主题
                </label>
                <span class="wspan" style="overflow: hidden; word-wrap: break-word;">{{modelData.HDTitle}}</span>
            </div>
            <div class="ui-form-item ui-border-b" style="height:auto">
                <label>
                    活动简介
                </label>
                <span class="wspan "></span>
                <p class="span" ms-if="modelData.HDContent" ms-html="modelData.HDContent"></p>
                <div style="clear: both"></div>
            </div>
            <div class="ui-form-item ui-border-b" style="height:auto;min-height:44px" ms-if="tpData.size()>0">
                <label>
                    图片
                </label>
                <div class="wspan" style="padding-top:10px">
                    <span ms-repeat-fl="tpData">
                        <img ms-click="fdtp(this)" ms-if="MobileCom.xstp(fl.FileExtendName)" class="mall_pcp" ms-src="imgurl+'image/'+fl.FileMD5" style="width:60px;height:60px;padding-right: 5px;" />
                    </span>
                    <span ms-repeat-fls="tpData">
                        <img ms-click="fdtp(this)" ms-if="!MobileCom.xstp(fls.FileExtendName)" class="mall_pcp" ms-attr-src="'/MobileView/Images/qywd/'+fls.FileExtendName+'.png'" style="width:60px;height:60px;padding-right: 5px;" />
                    </span>
                </div>
            </div>
            <div class="ui-form-item ui-border-b">
                <label>
                    已报名人数
                </label>
                <span class="wspan">{{num}}</span>
                <a id="ckbm" class="ui-btn-lg ui-btn-primary" ms-click="ckbm()" style="float: right; display: none;width: auto; height: 30px; line-height: 30px; margin-top: 7px;">查看</a>
            </div>
            <div class="ui-form-item ui-border-b">
                <label>
                    是否报名
                </label>
                <span class="wspan">{{status}}</span>
                <a id="bmcj" class="ui-btn-lg ui-btn-primary" ms-click="bmcj()" style="float: right; display: none;width: auto; height: 30px; line-height: 30px; margin-top: 7px;">报名</a>
            </div>
            
            <div class="ui-form-item ui-border-b">
                <label>
                    评论区
                </label>
                <span class="wspan">共 {{plcount}} 条评论</span>
            </div>
            <div class="ui-form ui-border-t">
                <ul class="ui-list ui-list-pure">
                    <li class="ui-border ui-label-list" ms-repeat-el="plData">
                        <div style="display: -webkit-box;">
                            <div class="ui-avatar-s">
                                <span ms-css-background-image="url(/Upload/TX/{{el.CRUser}}.jpg)"></span>
                            </div>
                            <div class="ui-list-info">
                                <h4>{{el.CRUserName}}</h4>
                            </div>
                            <div class="ui-list-info">
                                <p>{{el.CRDate|date("yyyy-MM-dd HH:mm")}}</p>
                            </div>
                            <!--{{issc(el.CRUser)|html }}-->

                        </div>
                        <p class="ui-txt-justify" ms-html="el.MSGContent" style="overflow: hidden; word-wrap: break-word;"></p>
                    </li>
                </ul>
            </div>
        </div>


    </section>
</body>
</html>
